using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class TF_EventMarket {
		#region Fields
		private int iD;
		private int eventLineId;
		private int eventId;
		private int cityID;
		private int marketID;
		private string startDate;
		private string startTime;
		private string endDate;
		private string endTime;
		private string remark;
		private int lanuageId;
		private int scheduleStatus;
		private int stepDay;
		private string locCode;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the TF_EventMarket class.
		/// </summary>
		public TF_EventMarket() {
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_EventMarket class.
		/// </summary>
		public TF_EventMarket(int eventLineId, int eventId, int cityID, int marketID, string startDate, string startTime, string endDate, string endTime, string remark, int lanuageId, int scheduleStatus, int stepDay, string locCode) {
			this.eventLineId = eventLineId;
			this.eventId = eventId;
			this.cityID = cityID;
			this.marketID = marketID;
			this.startDate = startDate;
			this.startTime = startTime;
			this.endDate = endDate;
			this.endTime = endTime;
			this.remark = remark;
			this.lanuageId = lanuageId;
			this.scheduleStatus = scheduleStatus;
			this.stepDay = stepDay;
			this.locCode = locCode;
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_EventMarket class.
		/// </summary>
		public TF_EventMarket(int iD, int eventLineId, int eventId, int cityID, int marketID, string startDate, string startTime, string endDate, string endTime, string remark, int lanuageId, int scheduleStatus, int stepDay, string locCode) {
			this.iD = iD;
			this.eventLineId = eventLineId;
			this.eventId = eventId;
			this.cityID = cityID;
			this.marketID = marketID;
			this.startDate = startDate;
			this.startTime = startTime;
			this.endDate = endDate;
			this.endTime = endTime;
			this.remark = remark;
			this.lanuageId = lanuageId;
			this.scheduleStatus = scheduleStatus;
			this.stepDay = stepDay;
			this.locCode = locCode;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the ID value.
		/// </summary>
		public int ID {
			get { return iD; }
			set { iD = value; }
		}
		
		/// <summary>
		/// Gets or sets the EventLineId value.
		/// </summary>
		public int EventLineId {
			get { return eventLineId; }
			set { eventLineId = value; }
		}
		
		/// <summary>
		/// Gets or sets the EventId value.
		/// </summary>
		public int EventId {
			get { return eventId; }
			set { eventId = value; }
		}
		
		/// <summary>
		/// Gets or sets the CityID value.
		/// </summary>
		public int CityID {
			get { return cityID; }
			set { cityID = value; }
		}
		
		/// <summary>
		/// Gets or sets the MarketID value.
		/// </summary>
		public int MarketID {
			get { return marketID; }
			set { marketID = value; }
		}
		
		/// <summary>
		/// Gets or sets the StartDate value.
		/// </summary>
		public string StartDate {
			get { return startDate; }
			set { startDate = value; }
		}
		
		/// <summary>
		/// Gets or sets the StartTime value.
		/// </summary>
		public string StartTime {
			get { return startTime; }
			set { startTime = value; }
		}
		
		/// <summary>
		/// Gets or sets the EndDate value.
		/// </summary>
		public string EndDate {
			get { return endDate; }
			set { endDate = value; }
		}
		
		/// <summary>
		/// Gets or sets the EndTime value.
		/// </summary>
		public string EndTime {
			get { return endTime; }
			set { endTime = value; }
		}
		
		/// <summary>
		/// Gets or sets the Remark value.
		/// </summary>
		public string Remark {
			get { return remark; }
			set { remark = value; }
		}
		
		/// <summary>
		/// Gets or sets the LanuageId value.
		/// </summary>
		public int LanuageId {
			get { return lanuageId; }
			set { lanuageId = value; }
		}
		
		/// <summary>
		/// Gets or sets the ScheduleStatus value.
		/// </summary>
		public int ScheduleStatus {
			get { return scheduleStatus; }
			set { scheduleStatus = value; }
		}
		
		/// <summary>
		/// Gets or sets the StepDay value.
		/// </summary>
		public int StepDay {
			get { return stepDay; }
			set { stepDay = value; }
		}
		
		/// <summary>
		/// Gets or sets the LocCode value.
		/// </summary>
		public string LocCode {
			get { return locCode; }
			set { locCode = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the TF_EventMarket table.
		/// </summary>
		public void Insert() {
			iD = Convert.ToInt32(SqlClientUtility.ExecuteScalar("TF_EventMarketInsert", eventLineId, eventId, cityID, marketID, startDate, startTime, endDate, endTime, remark, lanuageId, scheduleStatus, stepDay, locCode));
		}
		
		/// <summary>
		/// Updates a record in the TF_EventMarket table.
		/// </summary>
		public void Update() {
			SqlClientUtility.ExecuteNonQuery("TF_EventMarketUpdate", iD, eventLineId, eventId, cityID, marketID, startDate, startTime, endDate, endTime, remark, lanuageId, scheduleStatus, stepDay, locCode);
		}
		
		/// <summary>
		/// Deletes a record from the TF_EventMarket table by its primary key.
		/// </summary>
		public void Delete() {
			SqlClientUtility.ExecuteNonQuery("TF_EventMarketDelete", iD);
		}
		
		/// <summary>
		/// Selects a single record from the TF_EventMarket table.
		/// </summary>
		public static TF_EventMarket Select(int iD) {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_EventMarketSelect", iD)) {
				if (dataReader.Read()) {
					return MakeTF_EventMarket(dataReader);
				} else {
					return null;
				}
			}
		}
		
		/// <summary>
		/// Selects all records from the TF_EventMarket table.
		/// </summary>
		public static List<TF_EventMarket> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_EventMarketSelectAll")) {
				List<TF_EventMarket> tF_EventMarketList = new List<TF_EventMarket>();
				while (dataReader.Read()) {
					TF_EventMarket tF_EventMarket = MakeTF_EventMarket(dataReader);
					tF_EventMarketList.Add(tF_EventMarket);
				}
				return tF_EventMarketList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the TF_EventMarket class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static TF_EventMarket MakeTF_EventMarket(SqlDataReader dataReader) {
			TF_EventMarket tF_EventMarket = new TF_EventMarket();
			
			if (dataReader.IsDBNull(0) == false) {
				tF_EventMarket.ID = dataReader.GetInt32(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				tF_EventMarket.EventLineId = dataReader.GetInt32(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				tF_EventMarket.EventId = dataReader.GetInt32(2);
			}
			if (dataReader.IsDBNull(3) == false) {
				tF_EventMarket.CityID = dataReader.GetInt32(3);
			}
			if (dataReader.IsDBNull(4) == false) {
				tF_EventMarket.MarketID = dataReader.GetInt32(4);
			}
			if (dataReader.IsDBNull(5) == false) {
				tF_EventMarket.StartDate = dataReader.GetString(5);
			}
			if (dataReader.IsDBNull(6) == false) {
				tF_EventMarket.StartTime = dataReader.GetString(6);
			}
			if (dataReader.IsDBNull(7) == false) {
				tF_EventMarket.EndDate = dataReader.GetString(7);
			}
			if (dataReader.IsDBNull(8) == false) {
				tF_EventMarket.EndTime = dataReader.GetString(8);
			}
			if (dataReader.IsDBNull(9) == false) {
				tF_EventMarket.Remark = dataReader.GetString(9);
			}
			if (dataReader.IsDBNull(10) == false) {
				tF_EventMarket.LanuageId = dataReader.GetInt32(10);
			}
			if (dataReader.IsDBNull(11) == false) {
				tF_EventMarket.ScheduleStatus = dataReader.GetInt32(11);
			}
			if (dataReader.IsDBNull(12) == false) {
				tF_EventMarket.StepDay = dataReader.GetInt32(12);
			}
			if (dataReader.IsDBNull(13) == false) {
				tF_EventMarket.LocCode = dataReader.GetString(13);
			}

			return tF_EventMarket;
		}
		#endregion
	}
}
